home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / SPAWNO41.ARJ / SYSTEM.C < prev    next >
C/C++ Source or Header  |  1991-11-04  |  2KB  |  50 lines

  1. /********************************************************************/
  2. /*   SPAWNO v4.0   EMS/XMS/disk swapping replacement for spawn...() */
  3. /*   (c) Copyright 1991 Ralf Brown  All Rights Reserved         */
  4. /*                                    */
  5. /*   May be freely copied provided that this copyright notice is    */
  6. /*   not altered or removed.                        */
  7. /********************************************************************/
  8.  
  9. #include "_spawno.h"
  10. #include <dos.h>
  11. #include <io.h>
  12.  
  13. int _Cdecl systemo(const char *overlay_path, const char *command)
  14. {
  15.    char *comspec = getenv("COMSPEC") ;
  16.    char c_switch[3] ;
  17.  
  18.    if (!comspec || *comspec == '\0')    /* if no COMSPEC environment variable, */
  19.       comspec = "COMMAND" ;             /* use COMMAND as the default          */
  20.    if (!command || *command == '\0')    /* if given a null command, system()   */
  21.       {                 /* returns whether or not the command  */
  22.       if (!access(__spawn_search(comspec),0))  /* processor is accessible      */
  23.      return 1 ;
  24.       else
  25.      {
  26.      errno = ENOENT ;
  27.      return 0 ;
  28.      }
  29.       }
  30. #ifdef __TURBOC__
  31.    _AX = 0x3700 ;
  32.    geninterrupt(0x21) ;
  33.    if (_AL)
  34.       c_switch[0] = '/' ;
  35.    else
  36.       c_switch[0] = _DL ;
  37. #else
  38.    c_switch[0] = '/' ;
  39. #endif
  40.    c_switch[1] = 'c' ;
  41.    c_switch[2] = '\0' ;
  42. #ifdef USE_ENVP
  43.    return spawnlpeo(overlay_path,comspec,comspec,c_switch,command,(char *)NULL,
  44.             ENVP) ;
  45. #else
  46.    return spawnlpo(overlay_path,comspec,comspec,c_switch,command,(char *)NULL) ;
  47. #endif /* USE_ENVP */
  48. }
  49.  
  50.